<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //自定义对象
        /*   var huaAn = {
              //属性
              id: 9527,
              name: '华安',
              age: 23,
              isMan: true,
              goCity: ["昆明", "大理"],
              //方法（函数）
              eat: function () {
                  alert("干饭~~"+this.name);
              },
              sleep: function () {
                  alert("睡觉~~")
              }
          } */



        //常规的变种写法 当属性和值一样时  写一个 函数省略function
        var id = 9527;
        var name = "华安";

        var huaAn = {
            id,
            name,
            age: 23,
            isMan: true,
            goCity: ["昆明", "大理"],
            eat() {
                alert("干饭~~" + this.name);
            },
            sleep() {
                alert("睡觉~~")
            }
        }




        //访问对象的属性或方法
        huaAn.name = "唐伯虎";
        console.log(huaAn.name);//华安

        huaAn.eat();//干饭


    </script>
</head>

<body>

</body>

</html>